package com.wits.qso.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import net.sf.json.JSONObject;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

import com.wits.platform.entity.BaseEntity;

/**
 * 作业附件实体
 */
@Entity
@Table(name = "QSO_HOMEWORK_F")
public class HWKAttachment extends BaseEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = -134662070331150529L;
	/**
	 * 主键
	 */
	private String id = null;
//	/**
//	 * 作业Id
//	 */
//	private String hwkId;
	/**
	 * 作业
	 */
	private Homework homework;
	/**
	 * 原始名称
	 */
	private String oldName;
	/**
	 * 文件名称
	 */
	private String newName;

	/**
	 * 文件路径
	 */
	private String filePath;
	/**
	 * 相对路径
	 */
	private String fileUri = null;
	/**
	 * 附件大小
	 */
	private int fileSize;
	/**
	 * 附件说明
	 */
	private String description;

	public HWKAttachment() {
		super();
	}

	@Id
	@GenericGenerator(name = "idGen", strategy = "com.wits.platform.common.id.generator.IDGenerator", parameters = {
			@Parameter(name = "segment_value", value = "QSO_HWKF_ID"),
			@Parameter(name = "table_name", value = "wits_id_generator"),
			@Parameter(name = "value_column_name", value = "gen_value"),
			@Parameter(name = "segment_column_name", value = "gen_name"),
			@Parameter(name = "segment_value_length", value = "10"),
			@Parameter(name = "sq_format", value = "%08d"),
			@Parameter(name = "sq_prefix", value = "HF") })
	@GeneratedValue(generator = "idGen")
	@Column(name = "hwkf_id", nullable = false, insertable = true, updatable = false, length = 10)
	public String getId() {
		return id;
	}

	
	@Column(name = "file_desc", length = 500)
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setId(String id) {
		this.id = id;
	}

//	@Column(name = "hwk_id")
//	public String getHwkId() {
//		return hwkId;
//	}
//
//	public void setHwkId(String hwkId) {
//		this.hwkId = hwkId;
//	}

	@ManyToOne
	@JoinColumn(name = "hwk_id", updatable = true)
	public Homework getHomework() {
		return homework;
	}

	public void setHomework(Homework homework) {
		this.homework = homework;
	}
	
	@Column(name = "file_old_name", length = 100)
	public String getOldName() {
		return oldName;
	}

	public void setOldName(String oldName) {
		this.oldName = oldName;
	}
	@Column(name = "file_new_name", length = 100)
	public String getNewName() {
		return newName;
	}

	public void setNewName(String newName) {
		this.newName = newName;
	}
	@Column(name = "file_path", length = 200)
	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	@Column(name = "file_uri", length = 100)
	public String getFileUri() {
		return fileUri;
	}

	public void setFileUri(String fileUri) {
		this.fileUri = fileUri;
	}
	@Column(name = "file_size")
	public int getFileSize() {
		return fileSize;
	}

	public void setFileSize(int fileSize) {
		this.fileSize = fileSize;
	}

	public String display() {
		// TODO Auto-generated method stub
		return null;
	}

	public String toString() {
		return JSONObject.fromObject(this, HWKAttachment.getBaseJsonConfig())
				.toString();
	}
}
